package com.dt76.smallloanbackenduser.controller.hzp;

import com.dt76.smallloanbackenduser.remote.hzp.HLoanMaterialRemote;
import com.dt76.smallloanbackenduser.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/hzp")
public class HLoanMaterialController {
    //远程服务器
    @Autowired
    private HLoanMaterialRemote hLoanMaterialRemote;

    @RequestMapping("/loanMaterial")
    public String qryAllHLMM(Model model) {
        Page page = hLoanMaterialRemote.qryPageHLoanMaterial(1, 5);
        model.addAttribute("hlmmList", page.getRows());
        model.addAttribute("indexPage", page.getPageIndex());
        model.addAttribute("totalPage", page.getTotalPageCount());
        return "/pages/hzp/loanMaterial";
    }

    //分页
    @RequestMapping("/PageloanMaterial/pageList/{page}")
    public String qryPageHLMM(Model model, @PathVariable Integer page) {
        if (page <= 0) {
            page = 1;
        }
        Page pager = hLoanMaterialRemote.qryPageHLoanMaterial(page, 5);
        model.addAttribute("hlmmList", pager.getRows());
        model.addAttribute("indexPage", pager.getPageIndex());
        model.addAttribute("totalPage", pager.getTotalPageCount());
        return "/pages/hzp/loanMaterial";
    }
    @RequestMapping("/1234")
    public String qry123(){
        return "/pages/hzp/sub/addLoanMaterial";
    }
    @RequestMapping("/567")
    public String qry1234(){
        return "/pages/hzp/chanpincanshu";
    }
//    @RequestMapping("/findOne/{materialId}")
//    @ResponseBody
//    public HLoanMaterial findOne(@PathVariable String materialId){
//        return hLoanMaterialRemote.findOne(Integer.parseInt(materialId));
//    }
//    @RequestMapping("/add")
//    public String add(HLoanMaterial hLoanMaterial){
//        Result result=hLoanMaterialRemote.add(hLoanMaterial);
//        if (result.isSuccess()){
//            return "forward:qryAllHLMM.do?currentPageNo=1";
//        }
//    }
}
